package com.jmx.demo2;

import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;

/**
 * First..
 *
 * @author Lizhong
 * @date 2019/4/24
 */
public class Producer extends NotificationBroadcasterSupport implements ProducerMBean {
    private String name;

    public Producer(String name) {
        this.name = name;
    }

    public Producer() {
        this.name = "First";
    }


    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName(String s) {
        this.name = s;
    }

    @Override
    public void printName() {
        System.out.println(name);
        Notification notify =
                //通知名称；谁发起的通知；序列号；发起通知时间；发送的消息
                new Notification("jack.hi", this, 1L, System.currentTimeMillis(), "jack");
        sendNotification(notify);
    }
}
